home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group01b.txt / 000175_icon-group-sender_Sat Nov 24 15:35:13 2001.msg < prev    next >
Internet Message Format  |  2002-01-03  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id fAOMVoQ22251
  4.     for icon-group-addresses; Sat, 24 Nov 2001 15:31:50 -0700 (MST)
  5. Message-Id: <200111242231.fAOMVoQ22251@baskerville.CS.Arizona.EDU>
  6. From: Art Eschenlauer <art.eschenlauer@sufsys.com>
  7. To: "'icon-group@CS.Arizona.EDU '" <icon-group@cs.arizona.edu>
  8. Subject: compact idiom to reference Nth result? e.g., every s := ("a"|"b"|
  9.     "c"|"d")\3 ; write (s)
  10. Date: Thu, 22 Nov 2001 05:40:23 -0600
  11. Errors-To: icon-group-errors@cs.arizona.edu
  12. Status: RO
  13. Content-Length: 1101
  14.  
  15. Is there a compact way to reference the Nth result in the set of results
  16. produced by an expression?
  17.  
  18. For example, suppose that I want to obtain the third result produced by the
  19. expression ("a"|"b"|"c"|"d").  Thinking in my stone-age procedural way, I
  20. would write:
  21.  
  22. procedure main()
  23.   i := 0
  24.   every s := ("a"|"b"|"c"|"d") do {
  25.     write ("s = "||s)
  26.     i +:= 1
  27.     if i = 3 then {
  28.       write ("i = "||i)
  29.       write(s)
  30.       break
  31.     }
  32.   }
  33. end
  34.  
  35. I suppose that I could do this with a co-expression:
  36.  
  37. procedure main()
  38.   E := create ("a"|"b"|"c"|"d")
  39.   i := 0
  40.   while s := ! @E do {
  41.     write ("s = "||s)
  42.     i +:= 1
  43.     if i = 3 then {
  44.       write ("i = "||i)
  45.       write(s)
  46.       break
  47.     }
  48.   }
  49. end
  50.  
  51. but I don't think that immediately gives me much benefit.
  52.  
  53. What I'm hoping for is a compact syntax, similar to one of the following
  54. examples except that it would actually work!
  55.   ("a"|"b"|"c"|"d")[3]
  56.   3("a"|"b"|"c"|"d")
  57.  
  58. The most compact idiom I have come up with is:
  59. every s := ("a"|"b"|"c"|"d")\3 ; write (s)
  60. Any suggestions? 
  61. Is there an idiomatic way to get rid of the variable s for example?
  62.